package com.hq.common.domain;

import com.hq.common.dao.EnvParamDao;
import com.hq.common.eventbus.EventBusManager;
import com.hq.common.initializer.AbstractInitializer;
import com.hq.common.utils.cipher.RSA;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 初始化系统参数
 */
@Component
public class SystemParamsInitializer extends AbstractInitializer {

    @Autowired
    private EnvParamDao envParamDao;

    @Override
    public void init() {
        initRSA();
        initEventBus();
    }

    private void initRSA() {
        String key = envParamDao.getEnvParam("RSAKEY");
        RSA.getInstance().initialize(key);
    }

    private void initEventBus() {
        EventBusManager.getInstance();
    }

    @Override
    public String getDesc() {
        return "系统参数初始化";
    }

    @Override
    public int getOrderNo() {
        return 0;
    }
}
